var height = document.body.clientHeight
$(".MessageCar").css("height",height-201);
function toMatch(){
	window.location.href="../html/match.html"
}
function toMe(){
	window.location.href="../html/Me.html"
}
var fn=0;
$(function(){
	$.ajax({
		url:"../messageController/message",
		data:{
			"fn":0
		},
		success:function(data){
			console.log(data);
			if(data==null || data=="" ||data.length==0){
				 $(".MessageCar").html("<div><img src='../image/none.jpg' style='width: 300px;height:300px;margin-left: 225px;margin-top:100px;'></div>");
			}else{
				$('.MessageCar').html("");
				fn=fn+20;
				$.each(data,function(idex,item){
					var createTime = new Date(item.createTime).format("yyyy-MM-dd hh:mm:ss");
					$('.MessageCar').append("<div class='Message'><div class='box'><div class='title'>"+item.title+"<div class='createTime'>"+createTime+"</div></div><div class='content'>"+item.content+"</div></div></div>")		
				})
			}
		},
		error:function(){
			alert("加载失败");
		}
 })
});
 const scrollDom = document.getElementById('MessageCar');

 scrollDom.onscroll = () => {
	if (scrollDom.clientHeight + parseInt(scrollDom.scrollTop) === scrollDom.scrollHeight) {
		$.ajax({
			url:"../messageController/message",
			data:{
				"fn":fn
			},
			success:function(data){
				fn=fn+20;
				$.each(data,function(idex,item){
					var createTime = new Date(item.createTime).format("yyyy-MM-dd hh:mm:ss");
					$('.MessageCar').append("<div class='Message'><div class='box'><div class='title'>"+item.title+"<div class='createTime'>"+createTime+"</div></div><div class='content'>"+item.content+"</div></div></div>")		
				})
				
			},
			error:function(){
				alert("加载失败");
			}
		})
	}
}